package apof.util
{
	public class Enumerater
	{
		
		public static function repeat (item:String, times:int) :String{
			var str:String=item;
			for(var i:int=1; i<times; i++) {
				str+=(" , "+item);
			}
			return str;
		}
		
		public static function enumerateArray(s:Array,separator:String=" , "):String {
			var str:String=s[0].toString();
			for(var i:int=1; i<s.length; i++) {
				str+=(separator+s[i].toString());
			}
			return str;
		}
		
		public static function enumerateKeys(map:Object,separator:String=" , "):String {
			var str:String="";
			for (var key:String in map) {
				str+=(key+separator)
			}
			return str;
		}
		
		public static function enumerate2Arrays(s:Array,t:Array):String {
			var str:String=s[0].toString()+" "+t[0].toString();
			for(var i:int=1; i<s.length; i++) {
				str+=(" ,\n "+s[i].toString()+" "+t[i].toString());
			}
			return str;
		}
		
		public static function enumerateProperties(obj:Object,entries:Array):String {
			var str:String=obj[entries[0]];
			for(var i:int=1; i<entries.length; i++) {
				str+=(" , " + obj[entries[i]]);
			}
			return str;
		}
		
		public static function enumerateMappings(obj:Object,entries:Array,separator:String="="):String {
			var str:String=entries[0] + separator + obj[entries[0]];
			for(var i:int=1; i<entries.length; i++) {
				str+=(" ,\n " + entries[i] + separator + obj[entries[i]]);
			}
			return str;
		}
		
		public static function copyArray(source:Array, destin:Array):void {
			for(var i:int=0;i<source.length;i++)
				destin[i]=source[i];
		}
		
		public static function listProperties(obj:Object,entries:Array):Array {
			var arr:Array=new Array();
			for(var i:int=0; i<entries.length; i++) {
				arr.push(obj[entries[i]]);
			}
			return arr;
		}
	}
}